home *** CD-ROM | disk | FTP | other *** search
/ PC Play 129 / pc play 129.iso / Demo / man2 / man2.exe / data / scripts / starship_scripts.lua < prev    next >
Encoding:
Text File  |  2005-02-11  |  9.4 KB  |  258 lines

  1.  
  2. function units_starship_setup()
  3.     units_setup(7,false,nil)
  4.     uniGetExecutor():setLocalOrientation(0,1,0,0,0,1)
  5. end
  6.  
  7. function units_starship_resetup()
  8.     units_setup(7,false,nil)
  9.     uniGetExecutor():setLocalOrientation(0,1,0,0,0,1)
  10. end
  11.  
  12. function units_starship_select()
  13.     units_select(12,1)
  14. end
  15.  
  16. function units_starship_unselect()
  17.     units_unselect()
  18. end
  19.  
  20. function units_starship_selectenemy()
  21.     uniGetExecutor():addSimpleEffect(ENET_EFFECT_SELECTEDGEOMETRY_ENEMY)
  22. end
  23.  
  24. function units_starship_damaged()
  25.     uniGetExecutor():applyDamage(uniGetLife())
  26. end
  27.  
  28. function units_starship_highlight()
  29.     local ship = uniGetExecutor()
  30.     local wPos = ship:getWorldPosition()
  31. --    ship:setLocalPosition(wPos.x,wPos.y + 300,wPos.z + 300)
  32.     ship:setLocalPosition(wPos.x,wPos.y,wPos.z + 300)
  33.     wPos.y = getHeight(wPos.x,wPos.z)
  34.     wPos.z = wPos.z + 100
  35.     waitDeath(ship:linearFly(wPos,300,true))
  36.     uniSetLife(1.0)
  37.     ship:executeCommand(ENC_DAMAGED)
  38. --    uniGetExecutor():applyDamage(2.0)
  39. end
  40.  
  41. function units_starship_explode()
  42.     units_explode_xxl1()
  43. end
  44.  
  45. function units_starship_move()
  46.     local ship = uniGetExecutor()
  47.     local pos = D3DXVECTOR3:new(0,0,0)
  48.  
  49.     local to = D3DXVECTOR3:new(uniGetPosition().x - ship:getWorldPosition().x, 0, uniGetPosition().z - ship:getWorldPosition().z)
  50.  
  51.     local top_smoke1 = ship:getBone(ENBT_FIRE2,6):addSimpleEffect(ENET_EFFECT_PS_STARSHIP_FLY3)
  52.     local top_smoke2 = ship:getBone(ENBT_FIRE2,7):addSimpleEffect(ENET_EFFECT_PS_STARSHIP_FLY3)
  53.     local top_smoke3 = ship:getBone(ENBT_FIRE2,9):addSimpleEffect(ENET_EFFECT_PS_STARSHIP_FLY3)
  54.  
  55.     if ( to.x * to.x + to.z * to.z > 10 ) then
  56.  
  57.         local down_engine1 = ship:getBone(ENBT_FIRE2,5):addSimpleEffect(ENET_EFFECT_PS_STARSHIP_FLY1)
  58.         local down_engine2 = ship:getBone(ENBT_FIRE2,8):addSimpleEffect(ENET_EFFECT_PS_STARSHIP_FLY1)
  59.         local down_engine3 = ship:getBone(ENBT_FIRE2,0):addSimpleEffect(ENET_EFFECT_PS_STARSHIP_FLY1)
  60.  
  61.  
  62.         pos = ship:getWorldPosition()
  63.         pos.y = pos.y + 250
  64.         waitDeath(ship:starshipFly(pos,30))
  65.  
  66.  
  67.         waitDeath(ship:addRotationEffect(ENET_EFFECT_ROTATE_UNIT,MATH_PI * 0.25))
  68.  
  69.         down_engine1:suspendedDestroy(1.5)
  70.         down_engine2:suspendedDestroy(1.5)
  71.         down_engine3:suspendedDestroy(1.5)
  72.  
  73.         pos = uniGetPosition()
  74.         pos.y = pos.y + 250
  75.  
  76.         local back_engine1 = ship:getBone(ENBT_FIRE2,1):addSimpleEffect(ENET_EFFECT_PS_STARSHIP_FLY2)
  77.         local back_engine2 = ship:getBone(ENBT_FIRE2,2):addSimpleEffect(ENET_EFFECT_PS_STARSHIP_FLY2)
  78.         local back_engine3 = ship:getBone(ENBT_FIRE2,3):addSimpleEffect(ENET_EFFECT_PS_STARSHIP_FLY2)
  79.         local back_engine4 = ship:getBone(ENBT_FIRE2,4):addSimpleEffect(ENET_EFFECT_PS_STARSHIP_FLY2)
  80.  
  81.         waitDeath(ship:starshipFly(pos,200))
  82.  
  83.         back_engine1:suspendedDestroy(2.5)
  84.         back_engine2:suspendedDestroy(2.5)
  85.         back_engine3:suspendedDestroy(2.5)
  86.         back_engine4:suspendedDestroy(2.5)
  87.     end
  88.  
  89.     pos:delete()
  90.     to:delete()
  91.  
  92.     local down_engine1 = ship:getBone(ENBT_FIRE2,5):addSimpleEffect(ENET_EFFECT_PS_STARSHIP_FLY1)
  93.     local down_engine2 = ship:getBone(ENBT_FIRE2,8):addSimpleEffect(ENET_EFFECT_PS_STARSHIP_FLY1)
  94.     local down_engine3 = ship:getBone(ENBT_FIRE2,0):addSimpleEffect(ENET_EFFECT_PS_STARSHIP_FLY1)
  95.  
  96.  
  97.     local rot = ship:addRotationEffect(ENET_EFFECT_ROTATE_RADAR,MATH_PI/3)
  98.     waitDeath(ship:starshipFly(uniGetPosition(),200))
  99.     rot:destroy()
  100.  
  101.     down_engine1:suspendedDestroy(1.5)
  102.     down_engine2:suspendedDestroy(1.5)
  103.     down_engine3:suspendedDestroy(1.5)
  104.  
  105.  
  106.     top_smoke1:suspendedDestroy(2.5)
  107.     top_smoke2:suspendedDestroy(2.5)
  108.     top_smoke3:suspendedDestroy(2.5)
  109. end
  110.  
  111. function units_starship_fire()
  112.     local ship = uniGetExecutor()
  113.     local pos = ship:getWorldPosition()
  114.  
  115.     local top_smoke1 = ship:getBone(ENBT_FIRE2,6):addSimpleEffect(ENET_EFFECT_PS_STARSHIP_FLY3)
  116.     local top_smoke2 = ship:getBone(ENBT_FIRE2,7):addSimpleEffect(ENET_EFFECT_PS_STARSHIP_FLY3)
  117.     local top_smoke3 = ship:getBone(ENBT_FIRE2,9):addSimpleEffect(ENET_EFFECT_PS_STARSHIP_FLY3)
  118.  
  119.     local down_engine1 = ship:getBone(ENBT_FIRE2,5):addSimpleEffect(ENET_EFFECT_PS_STARSHIP_FLY1)
  120.     local down_engine2 = ship:getBone(ENBT_FIRE2,8):addSimpleEffect(ENET_EFFECT_PS_STARSHIP_FLY1)
  121.     local down_engine3 = ship:getBone(ENBT_FIRE2,0):addSimpleEffect(ENET_EFFECT_PS_STARSHIP_FLY1)
  122.  
  123.     local rot = ship:addRotationEffect(ENET_EFFECT_ROTATE_RADAR,MATH_PI/3)
  124.  
  125.     pos.y = pos.y + uniGetMaxLife()
  126.     waitDeath(ship:starshipFly(pos,200))
  127.     rot:destroy()
  128.  
  129.     down_engine1:suspendedDestroy(1.5)
  130.     down_engine2:suspendedDestroy(1.5)
  131.     down_engine3:suspendedDestroy(1.5)
  132.  
  133.     top_smoke1:suspendedDestroy(2.5)
  134.     top_smoke2:suspendedDestroy(2.5)
  135.     top_smoke3:suspendedDestroy(2.5)
  136. end
  137.  
  138. function units_starship_load()
  139.     local unit = uniGetExecutor()
  140.     local cargo = uniGetTarget()
  141.     units_waitCommandByUID(cargo,unit:getCurrentCommandUID() - 1)
  142.     cargo:setVisibility(true,false)
  143.     uniSetPosition(unit:getBone(ENBT_FIRE1):getWorldPosition())
  144.     units_load_shrink(cargo)
  145.     local ground = units_addGround(unit,ENET_LTRANSPORT_GROUND)
  146.     local movecmd_uid = cargo:executeCommand(ENC_MOVE,true)
  147.     cargo:terminateCommand()
  148.     while(cargo:getCurrentCommandUID() == movecmd_uid) do pause() end
  149.     cargo:setTransformOwner(units_findfreefirespot(unit,1))
  150.     unit:setCurrentAnimationRepeatCount(0)
  151.     cargo:setVisibility(false,false)
  152. end
  153.  
  154. function units_starship_unload()
  155.  
  156.     local ship = uniGetExecutor()
  157.  
  158.     local top_smoke1 = ship:getBone(ENBT_FIRE2,6):addSimpleEffect(ENET_EFFECT_PS_STARSHIP_FLY3)
  159.     local top_smoke2 = ship:getBone(ENBT_FIRE2,7):addSimpleEffect(ENET_EFFECT_PS_STARSHIP_FLY3)
  160.     local top_smoke3 = ship:getBone(ENBT_FIRE2,9):addSimpleEffect(ENET_EFFECT_PS_STARSHIP_FLY3)
  161.  
  162.     local down_engine1 = ship:getBone(ENBT_FIRE2,5):addSimpleEffect(ENET_EFFECT_PS_STARSHIP_FLY1)
  163.     local down_engine2 = ship:getBone(ENBT_FIRE2,8):addSimpleEffect(ENET_EFFECT_PS_STARSHIP_FLY1)
  164.     local down_engine3 = ship:getBone(ENBT_FIRE2,0):addSimpleEffect(ENET_EFFECT_PS_STARSHIP_FLY1)
  165.  
  166.     local unit = uniGetExecutor()
  167.     local cargo = uniGetTarget()
  168.     units_waitCommandByUID(cargo,unit:getCurrentCommandUID() - 1)
  169.     cargo:setLocalOrientation(0,1,0,0,0,-1)
  170.     cargo:setTransformOwner()
  171.     cargo:setScale(0.4,0.4,0.4)
  172.     cargo:setVisibility(true,false)
  173.     local movecmd_uid = cargo:executeCommand(ENC_MOVE,true)
  174.     cargo:terminateCommand()
  175.     while(cargo:getCurrentCommandUID() == movecmd_uid) do pause() end
  176.     units_unload_growth(cargo)
  177.     cargo:setVisibility(true,true)
  178.  
  179.     down_engine1:suspendedDestroy(1.5)
  180.     down_engine2:suspendedDestroy(1.5)
  181.     down_engine3:suspendedDestroy(1.5)
  182.  
  183.     top_smoke1:suspendedDestroy(2.5)
  184.     top_smoke2:suspendedDestroy(2.5)
  185.     top_smoke3:suspendedDestroy(2.5)
  186. end
  187.  
  188. registerCommand(ENSCRIPTSET_STARSHIP,ENC_MOVE,"units_starship_move")
  189. registerCommand(ENSCRIPTSET_STARSHIP,ENC_FIRE1,"units_starship_fire")
  190. registerCommand(ENSCRIPTSET_STARSHIP,ENC_FIRE2,"units_starship_fire")
  191. registerCommand(ENSCRIPTSET_STARSHIP,ENC_SELECT,"units_starship_select")
  192. registerCommand(ENSCRIPTSET_STARSHIP,ENC_SELECTENEMY,"units_starship_selectenemy")
  193. registerCommand(ENSCRIPTSET_STARSHIP,ENC_UNSELECT,"units_starship_unselect")
  194. registerCommand(ENSCRIPTSET_STARSHIP,ENC_SETUP,"units_starship_setup")
  195. registerCommand(ENSCRIPTSET_STARSHIP,ENC_RESETUP,"units_starship_resetup")
  196. registerCommand(ENSCRIPTSET_STARSHIP,ENC_DAMAGED,"units_starship_damaged")
  197. registerCommand(ENSCRIPTSET_STARSHIP,ENC_EXPLODE,"units_starship_explode")
  198. registerCommand(ENSCRIPTSET_STARSHIP,ENC_HIGHLIGHT,"units_starship_highlight")
  199. registerCommand(ENSCRIPTSET_STARSHIP,ENC_INSIDE,"units_inside")
  200. registerCommand(ENSCRIPTSET_STARSHIP,ENC_UNLOAD,"units_starship_unload")
  201. registerCommand(ENSCRIPTSET_STARSHIP,ENC_LOAD,"units_starship_load")
  202.  
  203. -- make description of unit
  204. desc = getEffectDescriptionP(ENET_UNIT_STARSHIP)
  205. desc.ClassID = ENCLASS_MESHINSTANCE
  206. desc.EffectClassType = ENECT_GEOMETRY
  207. desc.FileName = "starship.rmd"
  208. desc.ScriptSet = ENSCRIPTSET_STARSHIP
  209. desc.MoveType = ENMOVE_FLY
  210. desc.RenderType = ENRENDERTYPE_GEOMETRY
  211. desc.Material = ENMAT_RIGIDSKINNEDMESH
  212. desc.MaterialColors = units_materialcolors_human
  213.  
  214. -- shadow
  215. desc = getEffectDescriptionP(ENET_GEOMETRY_STARSHIP_SHADOW)
  216. desc.ClassID = ENCLASS_MESHINSTANCE
  217. desc.EffectClassType = ENECT_GEOMETRY
  218. desc.FileName = "starship_shadow.rmd"
  219. desc.RenderType = ENRENDERTYPE_SHADOW
  220. desc.Material = ENMAT_SHADOW
  221. desc.MaterialColors = units_materialcolors_shadow
  222.  
  223. -- register new unit to logic
  224. unitDesc = logic_getUnitDescP(98)
  225. unitDesc.group = 0
  226. unitDesc.order = 0
  227. unitDesc.unit_res_id = ENET_UNIT_STARSHIP
  228. unitDesc.unit_icon_id = "Spaceship_h_small_normal.dds"
  229. unitDesc.active_id = "Spaceship_h_small_active.dds"
  230. unitDesc.pressed_id = "Spaceship_h_small_pressed.dds"
  231. unitDesc.big_icon_id = "Spaceship_ico.dds"
  232. unitDesc.small_icon_id = "Smallrobot_u_stats.dds"
  233. unitDesc.HP = 1000
  234. unitDesc.MP = 10
  235. unitDesc.WR = 1
  236. unitDesc.min_WR = 1
  237. unitDesc.WD = 1
  238. unitDesc.WR2 = 0
  239. unitDesc.min_WR2 = 0
  240. unitDesc.WD2 = 0
  241. unitDesc.ability = 0
  242. unitDesc.transport = 6
  243. unitDesc.value = 1
  244. unitDesc.race = 0
  245. unitDesc.fire_pause = 0.2
  246. unitDesc.move_pause = 0.5
  247. unitDesc.unit_info_scale = 0.08
  248. unitDesc.scn_name = "STARSHIP"
  249.  
  250. ------------------------------------------------------------------------------------------------------
  251. ------------------------ effects related to unit------------------------------------------------------
  252. ------------------------------------------------------------------------------------------------------
  253. desc = getEffectDescription(ENET_EFFECT_GEOMETRY_VEGETATION_FURPALM)
  254. desc.FileName = "ponton_ground.smd"
  255. desc.effectUsageType = ENEUT_GENERIC
  256. desc.Geometry.isCollisionable = true
  257. changeEffect(ENET_PONTON_GROUND,desc)
  258.